package com.mornd.gulimall.search.web.v1;

import com.mornd.gulimall.search.entity.SearchResult;
import com.mornd.gulimall.search.service.ISearchService;
import com.mornd.gulimall.search.entity.SearchParam;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * @author: mornd
 * @dateTime: 2023/8/13 - 19:36
 */

@Controller
public class SearchController {
    @Resource
    private ISearchService searchService;

    @GetMapping({"/", "/search", "/search.html"})
    public String searchPage(SearchParam searchParam, Model model, HttpSession session) {
        SearchResult result = searchService.search(searchParam);
        model.addAttribute("result", result);
        return "search";
    }
}
